<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Reservation_class extends CI_Model {
	
	
	public function insert($post)
	{
		$strFirstName = stripslashes(filter_var($post['strFirstName'], FILTER_SANITIZE_STRING));
		$strLastName = stripslashes(filter_var($post['strLastName'], FILTER_SANITIZE_STRING));
		$strEmail = stripslashes(filter_var($post['strEmail'], FILTER_SANITIZE_STRING));
		$strContactNumber = stripslashes(filter_var($post['strContactNumber'], FILTER_SANITIZE_STRING));
		$strPassword = stripslashes(filter_var($post['strPassword'], FILTER_SANITIZE_STRING));
		
		$data = array(
				'strFirstName' => $strFirstName,
				'strLastName' => $strLastName,
				'strEmail' => $strEmail,
				'strContactNumber' => $strContactNumber,
				'strPassword' => $this->encrypt->encode($strPassword),
				'dateCreated' => date('Y-m-d H:i:s')
		);
				
		$this->db->insert('reservation', $data);
		
		if($this->db->_error_number()==0)
		{
			$data['intStatus'] = 1;
		}
		else
		{
			$data['intStatus'] = 0; // Failed
		}
		return $data;
	}
		public function confirm($post)
	{
			$intRestoID = stripslashes(filter_var($post['intRestoID'], FILTER_SANITIZE_STRING));
		
		$data = array(	
				'strStatus' => 'Email Verification'
		);
		$this->db->where(array('intReservationID'=>$intRestoID));
		$this->db->update('reservation', $data);
		
		if($this->db->_error_number()==0)
		{
			$data['confirm'] = 1; // Success
		}
		else
		{
			$data['confirm'] = 2; // Failed
		}
		return $data;
	}
		public function deny($post)
	{
			$intRestoID = stripslashes(filter_var($post['intRestoID'], FILTER_SANITIZE_STRING));
		
		$data = array(	
				'strStatus' => 'denied'
		);
		$this->db->where(array('intReservationID'=>$intRestoID));
		$this->db->update('reservation', $data);
		
		if($this->db->_error_number()==0)
		{
			$data['confirm'] = 1; // Success
		}
		else
		{
			$data['confirm'] = 2; // Failed
		}
		return $data;
	}
}